注册

iMX283开发板实践历程-LED实验
首页 > 嵌入式开发 > Linux嵌入式    作者:RainFly   2016年1月21日 17:02 星期四   热度:11876°   字号:   评论:1    
时间:2016-1-21 17:02   热度:11876°  评论:1 条 

通过在开发板中输入命令 mount -t nfs 192.168.1.2:/nfsroot  /mnt  -o nolock

将开发板/mnt挂载到linux主机nfsroot目录下 实现文件传输共享!

在nfsroot目录下新建文件flash.c Makefile 

Makefile 用交叉编译器实现编译

# this makefile is to compile the light flashing!
EXE =flash
SRC =flash.c

CC = arm-none-linux-gnueabi-gcc
.PHONY:all clean
all:
$(CC) $(SRC) $^
clean:
-rm -v $(EXE)

flash.c文件内容

#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
void delaytime();
int main()
{
int time;
int t_fd,b_fd;
int t_ret,b_ret;
const char t_path[]="/sys/class/leds/led-err/trigger";
const char b_path[]="/sys/class/leds/led-err/brightness";
const char t_none[]="none";
const char b_true[1]="1";  //只写入一个字符'1'进入缓冲区
const char b_false[1]="0"; //同上
t_fd =open(t_path,O_RDWR);
printf("%s file describer is %d \n",t_path,t_fd);
b_fd =open(b_path,O_RDWR);
printf("%s file describer is %d \n",b_path,b_fd);

t_ret=write(t_fd,t_none,sizeof(t_none));
printf("write to trigger fd  %d\n",t_ret);

while(1)
{
for(time=2;time>0;time--)
{
if(2 == time)
{
b_ret=write(b_fd,b_true,1);
delaytime();
printf("%d\n",b_ret);
printf("write the 1 to b\n");
}
else
{
b_ret=write(b_fd,b_false,1);
delaytime();
printf("%d\n",b_ret);
printf("write the 0 to b\n");
}
}
}

return 0;
}
void  delaytime()   //延时函数
{
int i,j;
for(i=1000;i>0;i--)
for(j=10000;j>0;j--);
}



  您阅读这篇文章共花了:  
捐赠支持:如果觉得这篇文章对您有帮助,请 "扫一扫"鼓励作者!
二维码加载中...
本文作者:RainFly      文章标题: iMX283开发板实践历程-LED实验
本文地址:http://www.rainfly.cn/?post=172
版权声明:若无注明,本文皆为“雨夜轩”原创,转载请保留文章出处。

还有小板凳哦!

怎么网上赚钱  Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 7 Windows 7  2019-04-10 09:47 沙发
感谢博主分享。

QQ游客评论

返回顶部    首页    捐赠支持    手气不错    友情链接    关于我们    站长工具    站长介绍    手机版本    后台登陆   
版权所有:雨夜轩    站长:RainFly    特别鸣谢   文章归档   皖ICP备15003600号-1   百度统计
Copyright©2015 雨夜轩 Powered by emlog强力驱动 七牛CDN全球加速 360站长联盟安全认证 中国博客联盟荣誉成员 可信赖网站 站点地图   
页面加载耗时:0.033秒 数据库查询次数:13次
背景设置